package com.foreknow.demo8;

import java.util.Scanner;

/**
 * 封装类（包装类）：主要作用是用作类型的转换
 * 每一种基本数据类型都会对应一个包装类
 * byte--------Byte
 * short-------Short
 * int---------Integer
 * long--------Long
 * float-------Float
 * double------Double
 * char--------Character
 * boolean-----Boolean
 *
 * 面试题：int与Integer有什么区别？
 */

public class WarpDemo {
    public void m1(Integer i){
        System.out.println(i);
    }
    public Double m2(){
        return 3.14;
    }

    public static void main(String[] args) {
        WarpDemo warpDemo = new WarpDemo();
        warpDemo.m1(3);
        double d = warpDemo.m2();
        System.out.println(d);


        Integer i1 = new Integer(20);
        System.out.println(i1.toString());
        Integer i2 = new Integer(20);
        System.out.println(i1==i2);
        System.out.println(i1.equals(i2));

        System.out.println("------------");

//        Scanner input = new Scanner(System.in);
//        System.out.println("请输入一个数a：");
//        String num_a = input.next();
//        System.out.println("请输入一个数b：");
//        String num_b = input.next();
//
//        int a = Integer.parseInt(num_a);
//        int b = Integer.parseInt(num_b);
//        System.out.println(a+b);

        System.out.println("------------");

        int i = 34;
        Integer integer = new Integer(i);
        //jdk5之后还可以这么写
        Integer integer1 = 34;//自动装箱
        System.out.println(integer1);

        System.out.println("------------");
        Integer integer2 = 56;
        int x = integer2;//自动拆箱
        System.out.println(x);



    }
}
